home *** CD-ROM | disk | FTP | other *** search
/ Travel to Space / Travel to Space.iso / dos_prog / astronmy / mercury / manual. < prev    next >
Text File  |  1990-11-09  |  39KB  |  1,276 lines

  1.  
  2. Mercury 2.00 manual
  3. ===================
  4.  
  5. (C) Copyright 1990 Roger Schlafly.
  6. All Rights Reserved.
  7.  
  8. Portions of the software (C) Copyright 1987-88 Borland International.
  9. All Rights Reserved.
  10.  
  11.  
  12. Contents
  13. --------
  14.  
  15. 1. Introduction
  16.  Features
  17.  History
  18.  Shareware policy
  19.  Disclaimer
  20.  Files
  21.  Hardware Requirements
  22.  Installation
  23.  
  24. 2. Problems
  25.  Editing
  26.  Numbers
  27.  Operators
  28.  Constants
  29.  
  30. 3. Solving
  31.  Solutions
  32.  Graphs
  33.  Reports
  34.  
  35. 4. Feature Reference
  36.  Functions
  37.  Statements
  38.  Commands
  39.  
  40.  
  41.  
  42. 1. Introduction
  43.  
  44. Introduction
  45. ------------
  46.  
  47. Mercury is a program for solving equations on the IBM PC.  It is
  48. easy to use, interactive, and powerful.  With it, you can
  49.  
  50. * evaluate mathematical expressions.
  51.  
  52. * solve for the roots of an equation.
  53.  
  54. * solve a system of equations.
  55.  
  56. * maximize or minimize a function, with or without constraints.
  57.  
  58. * evaluate derivatives and definite integrals.
  59.  
  60. * plot one or more functions.
  61.  
  62. * print a report or a graph.
  63.  
  64. Mercury has a built-in editor, pull-down menus, online help,
  65. and all the conveniences necessary to make it accessible to
  66. computer novices.
  67.  
  68. For a quick demonstration of Mercury's capabilities, run MERCURY
  69. and then load and solve some of the sample problems (*.EKA).  If
  70. you get stuck, just press the F1 key for help.
  71.  
  72. Mercury is an outgrowth of Eureka, a product of Borland
  73. International of Scotts Valley, California.  When
  74. Borland decided to concentrate on spreadsheet and database
  75. products, Eureka was spun off.  Mercury was
  76. developed from that code base, and is being released in this
  77. form to satisfy customer requests for new versions of Eureka.  It
  78. is labelled version 2.0 because it is similar to what version 2.0 of
  79. Eureka would have been.
  80.  
  81. Eureka was also available on the Apple Macintosh.  No version
  82. of Mercury for the Macintosh is planned at this time.
  83.  
  84. Mercury is available as Shareware.  Shareware is a name for
  85. programs which are distributed freely or at nominal charge, but
  86. which are copyrighted and have restrictions on their usage.
  87.  
  88. Mercury may be copied freely for examination purposes.  Distributors
  89. may charge a nominal fee, provided that they adhere to the conditions in
  90. VENDOR.DOC.  Commercial and institutional use is prohibited
  91. without a registered license.  Such a license may be obtained by
  92. sending $49 to
  93.  
  94.     Real Software
  95.     PO Box 1680
  96.     Soquel, CA  95073
  97.     USA
  98.  
  99.     phone or fax: 408-476-3550
  100.     CompuServe: 76646,323
  101.  
  102. Payment may be by check, MasterCard, or Visa.  See REGISTER.DOC
  103. for an order form.
  104.  
  105. Those who register a license will get the latest version of the
  106. software, an installation program, and a printed manual.  They will
  107. be eligible for technical support, and will be on the mailing list
  108. for future information and updates.
  109.  
  110. Site licenses and other special arrangements are available.
  111.  
  112. Comments, bug reports, and suggestions are especially welcome.
  113.  
  114.  
  115. Disclaimer
  116. ----------
  117.  
  118. The author has made his best effort in producing this software, but
  119. hereby disclaims all warranties.  He will not be liable for any damages
  120. exceeding the price paid for the license to use the software.  The
  121. person using the software bears all risk as to the quality and
  122. performance of the software.
  123.  
  124. Mercury is not a Borland product.  Borland will not provide any
  125. technical support.  Eureka is a registered trademark of Borland
  126. International.  Borland copyrights and trademarks are used with
  127. permission.  Mercury is a trademark of the author.
  128.  
  129.  
  130. Files
  131. -----
  132.  
  133. Mercury consists of these files.
  134.  
  135. MERCURY.EXE           main program
  136. MERCURY.HLP           help file
  137. *.BGI                 graphics drivers
  138. *.CHR                 fonts
  139. *.EKA                 sample problems
  140. MANUAL                user manual (this file)
  141. README                quick instructions
  142. REGISTER.DOC          registration form
  143. VENDOR.DOC            vendor information
  144.  
  145. Auxilliary files:
  146.  
  147. *.EKA                 more sample problems
  148. *.BGI                 more graphics drivers
  149. *.BIN                 external functions
  150. *.C                   source to external functions
  151. MATHL.H               tools for making external functions
  152. *.OBJ                 tools for making external functions
  153. *.LIB                 tools for making external functions
  154.  
  155. If you downloaded Mercury from an online service, you may find the
  156. auxilliary files archived separately.  The extra files are not needed
  157. by most people, and are stored separately to save on connect time.
  158. The extra drivers are for uncommon hardware only, and the tools for
  159. making external functions require Borland's Turbo C++.
  160.  
  161. Registered customers also get INST.COM, an installation program
  162. for configurable options.
  163.  
  164.  
  165. Hardware Requirements
  166. ---------------------
  167.  
  168. Mercury requires an IBM PC or clone with at least 640K
  169. of RAM.  About 500K of free RAM is needed.  In addition,
  170. extended memory (EMS memory) is used if present.  If a
  171. math coprocessor is available, it will be used.  A math
  172. coprocessor is recommended for serious number crunchers.
  173.  
  174. Plots require a graphics monitor and a CGA, EGA, VGA, or
  175. Hercules card.
  176.  
  177. You can print reports and graphs on any of the popular
  178. printers.  Select Printer and Model from the Options menu
  179. for the list of supported printers.
  180.  
  181.  
  182. Installation
  183. ------------
  184.  
  185. There are no special installation requirements.  The simplest
  186. procedure is to make a new directory on your hard disk, and to
  187. copy all of the files there.  You may wish to put the Mercury
  188. directory on your path, or to copy some of the files to your
  189. RAM disk.
  190.  
  191. The program INST may be used to change the edit key bindings,
  192. and to make a few other installation choices.  Various other
  193. configuration options are available from within Mercury, and
  194. these may be saved to disk.  See Options, below.
  195.  
  196. Mercury tries to detect automatically what hardware is present,
  197. but there some situations where you may want to override the
  198. detection logic.
  199.  
  200. If you have a CGA monitor, it may or may not have the "snow"
  201. problem.  If so, you may notice random snow on the screen as
  202. characters are written there.  If so, you can eliminate it by
  203. typing
  204.  
  205.     set CGASNOWCHK=Y
  206.  
  207. at the DOS prompt before loading Mercury.  There must not be any spaces
  208. surrounding the equals sign.
  209.  
  210. Mercury automatically detects the math coprocessor, but
  211. occasionally Mercury fails because the chip is defective.  It can
  212. be turned off with
  213.  
  214.     set 87=N
  215.  
  216. at the DOS prompt.
  217.  
  218. Mercury also detects various graphics cards, but some cannot be
  219. detected.  See the SCREEN statement in Chapter 4.
  220.  
  221. If you have a graphics printer, you will want to select it at the
  222. Printer menu.  The graphics card and printer selection can be
  223. saved to the MERCURY.CFG file, and then it will be automatic each
  224. time Mercury is loaded.
  225.  
  226.  
  227. Errors
  228. ------
  229.  
  230. Error messages are pretty much self-explanatory.  If an error is
  231. detected while parsing the problem file, Mercury puts you in the
  232. Edit window with the cursor at the point of the error.  The error
  233. message at the top of the window, and disappears as soon as you
  234. start editing.  Other errors are displayed in a special box which
  235. is placed on the screen.  After you acknowledge the error by
  236. pressing the Escape key, you are put back in the menu system.
  237.  
  238.  
  239. 2. Problems
  240.  
  241. A problem is entered into Mercury by either loading an existing
  242. one from the disk, or by creating a new one in the Edit window.  This
  243. chapter explains how to use the editor, and how to create a problem
  244. for solving.
  245.  
  246.  
  247. Editing
  248. -------
  249.  
  250. Mercury includes a complete text editor for creating and
  251. modifying problem files.  Usage of the editor is similar
  252. to WordStar in nondocument mode, or to
  253. Borland's SideKick.  The problem files are
  254. ordinary ascii files, and can be edited with any other
  255. text editor.
  256.  
  257. You can move the cursor around in the editor with the arrow
  258. keys, Page Up, Page Down, and some other keys listed below.  The
  259. editor has two typing modes, Insert and Overwrite.  In Insert
  260. mode, anything you type is inserted at the cursor position.  In
  261. Overwrite mode, pressing a key replaces the current character
  262. at the cursor position with the new typed character.  Initially,
  263. the editor operates in Insert mode, a default you
  264. can change with the INST program.  To switch modes, press the
  265. Insert key or Ctrl-V.  (Ctrl-V means to hold down the Ctrl key
  266. on your keyboard while you press V.  The V need not be in upper
  267. case.)
  268.  
  269. No Word-Wrap
  270. Unlike a more standard word processing program, the editor does
  271. not have word-wrap.  You must press Enter at the end of each line.
  272.  
  273. AutoIndent
  274. The editor has an autoindent feature that allows subsequent lines
  275. to automatically indent.  If you leave several spaces at the
  276. start of a line, use Ctrl-OI to indent subsequent lines the same
  277. amount.  The command sequence is a toggle, so you need only
  278. press Ctrl-OI again to stop indenting.
  279.  
  280. Zoom
  281. Sometimes you may want to see more than the area covered by the
  282. current window.  You can "zoom" the window, expanding it to the
  283. size of the entire screen, by pressing F5.  To return the window
  284. to its usual size, press F5 again.  For other window commands,
  285. such as moving and resizing a window, see the Window menu, below.
  286.  
  287. Here is a summary of the editing commands.  Many of these
  288. commands can be changed with the INST installation program.
  289.  
  290.   Cursor Movement Commands:
  291.  
  292.   Character left         Ctrl-S or Left arrow
  293.   Character right        Ctrl-D or Right arrow
  294.   Word left              Ctrl-A
  295.   Word right             Ctrl-F
  296.   Line up                Ctrl-E or Up arrow
  297.   Line down              Ctrl-X or Down arrow
  298.   Scroll up              Ctrl-W
  299.   Scroll down            Ctrl-Z
  300.   Page up                Ctrl-R
  301.   Page down              Ctrl-C
  302.   Left of line           Ctrl-QS or Home
  303.   Right of line          Ctrl-QD or End
  304.   Top of screen          Ctrl-QE or Ctrl-Home
  305.   Bottom of screen       Ctrl-QX or Ctrl-End
  306.   Top of file            Ctrl-QR or Ctrl-PgUp
  307.   Bottom of file         Ctrl-QC or Ctrl-PgDn
  308.   Move to block begin    Ctrl-QB
  309.   Move to block end      Ctrl-QK
  310.   Move to previous point Ctrl-QP
  311.   Move to marker 0       Ctrl-Q0
  312.   Move to marker 1       Ctrl-Q1
  313.   Move to marker 2       Ctrl-Q2
  314.   Move to marker 3       Ctrl-Q3
  315.   Set marker 0           Ctrl-K0
  316.   Set marker 1           Ctrl-K1
  317.   Set marker 2           Ctrl-K2
  318.   Set marker 3           Ctrl-K3
  319.  
  320.   Insert & Delete Commands:
  321.  
  322.   Insert mode on/off     Ctrl-V or Ins
  323.   Insert line            Ctrl-N
  324.   Delete line            Ctrl-Y
  325.   Delete to end of line  Ctrl-QY
  326.   Delete character left  Ctrl-H or Backspace
  327.   Delete character       Ctrl-G or Del
  328.   Delete word right      Ctrl-T
  329.  
  330.   Block commands:
  331.  
  332.   Set block begin        Ctrl-KB or F7
  333.   Set block end          Ctrl-KK or F8
  334.   Mark word              Ctrl-KT
  335.   Hide block             Ctrl-KH
  336.   Copy block             Ctrl-KC
  337.   Move block             Ctrl-KV
  338.   Delete block           Ctrl-KY
  339.   Read block             Ctrl-KR
  340.   Write block            Ctrl-KW
  341.   Print block            Ctrl-KP
  342.  
  343.   Miscellaneous Commands:
  344.  
  345.   Quit edit, no save     Ctrl-KD, Ctrl-KQ, or Esc
  346.   Save and edit          Ctrl-KS or F2
  347.   New file               F3
  348.   Tab                    Ctrl-I or Tab
  349.   Tab mode toggle        Ctrl-OT
  350.   Auto indent on/off     Ctrl-OI
  351.   Restore line           Ctrl-QL
  352.   Find                   Ctrl-QF
  353.   Find & replace         Ctrl-QA
  354.   Repeat last find       Ctrl-L
  355.   Control key prefix     Ctrl-P
  356.   Abort operation        Ctrl-U
  357.   Restore error message  Ctrl-QW
  358.  
  359.   Search Options:
  360.  
  361.   B           Backwards search
  362.   G           Global search
  363.   n           n = any number. Search n times
  364.   N           Replace without asking
  365.   U           Ignore upper/lower case
  366.   W           Search for whole words only
  367.   S           Soundex
  368.  
  369.  
  370. Problems
  371. --------
  372.  
  373. A problem is a text (ascii) file consisting of comments,
  374. definitions, equations, and statements.  See the sample
  375. files for examples of problems.
  376.  
  377. Comments are not read by the Mercury solver, and serve
  378. merely for clarity or documentation.  A comment starts
  379. with a semicolon (;) and runs until the end of the line.
  380. Alternatively, comments can be enclosed in curly braces ({})
  381. and may occupy several lines.
  382.  
  383. Definitions may be either variable initializations or function
  384. definitions and are characterized by the := assignment
  385. operator.  If the left-hand-side is a name, it is taken to
  386. be a variable and the right-hand-side is an expression which
  387. evaluates to the initial value for that variable.  Such initial
  388. values can be critical to the iterative solver.  If the
  389. left-hand-side is a function, as in Square(x) := x^2, then the
  390. right-hand-side serves as the definition for that function.  In
  391. this case, Square is then a function of one argument, and
  392. Square(5) = 25.
  393.  
  394. Equations have a mathematical expression on each side of
  395. an equals sign (=).  An equation may also be an inequality
  396. constraint, in which case the equals sign is replaced by
  397. <, <=, >, or >=.
  398.  
  399. Statements are special directives to Mercury.  They are
  400. instructions either to do something other than solve the equations,
  401. or to control the solution process.  The allowed statements
  402. are listed below, and examples are in the problem files.
  403.  
  404.  
  405. Numbers
  406. -------
  407.  
  408. The range of numbers is plus or minus 1e-307 to 1e+307.
  409.  
  410. When using the exact solver, a question mark indicates that the
  411. next digit is uncertain.  For example, 1.23? indicates a number
  412. that might be anything between 1.225 and 1.235, as these are the
  413. numbers which round to 1.23.
  414.  
  415. Imaginary numbers are indicated with the suffix i.  For example,
  416. x = 2 + 3i is the complex number with real part 2 and imaginary
  417. part 3.
  418.  
  419. Percentages may be expressed with the suffix %.  For example, 5.1%
  420. is the same as .051.
  421.  
  422.  
  423. Examples
  424. --------
  425.  
  426. A number of example problem files (*.EKA) are on the program
  427. disk.  Examination of these is strongly recommended, as these
  428. demonstrate most of Mercury's features.  See Chapter 5.
  429.  
  430.  
  431. 3. Solving
  432.  
  433.  
  434. Solving
  435. -------
  436.  
  437. Mercury features three solver technologies.
  438.  
  439. 1. Direct solver.  This method consists of applying the rules of
  440. high school algebra to manipulate the equations until solutions are
  441. obtained for all the variables.  For example,
  442.  
  443.     2 x + 3 y = 8
  444.     4 x + 5 y = 14
  445.  
  446. can be solved directly by rearranging the first equation to
  447. y = (8 - 2 x)/3 and substituting for y in the second equation.
  448.  
  449. See the LEVEL statement for user control over what manipulations
  450. are allowed.
  451.  
  452. 2. Iterative solver.  The most difficult systems of equations cannot
  453. be solved analytically.  The best we can do is find some approximate
  454. solution and then apply some iterative procedure to improve the
  455. accuracy.  In such case it is advisable to provide starting values
  456. for the variables.
  457.  
  458. 3. Exact solver.  Mercury's most innovative feature is its ability
  459. to use exact methods in many cases.
  460.  
  461.  
  462. Solution Window
  463. ---------------
  464.  
  465. When you apply Solve to a problem file, the result is in the
  466. Solution Window.  The window is editable like the Edit window,
  467. and can be scrolled and zoomed for easy viewed.  The contents
  468. can be saved in a report, if that is desired.
  469.  
  470. The solution lists all of the variables, with their final
  471. values.  Usually, the value is just a number, displayed to
  472. however many digits is specified in the DIGITS statements or
  473. menu options.
  474.  
  475. In some cases, a variable was solved directly and symbolically
  476. in terms of other variables.  If such an expression was used
  477. to calculate the value, then the expression is shown.
  478.  
  479. If no value was ever assigned to the variable, then its value
  480. is given as "UNDEFINED" or "NO SOLUTION".  This occurs if the variable is
  481. used only as a dummy variable, such as in a function definition
  482. or as a variable of integration.
  483.  
  484. Occasionally, a variable value will be given as NAN, which
  485. means Not-A-Number.  This means the variable could not be computed
  486. accurately, and only crude bounds were obtained.  For example,
  487. a result "x = NAN(2.1,7.5)" indicates that x may be anything
  488. between 2.1 and 7.5.  Sometimes such imprecise results represent
  489. the best that can be said about an ill-posed problem, but sometimes
  490. it represents a failure on the part of Mercury.  Such results
  491. should be used with caution.
  492.  
  493. When a variable appears to have the value of a simple fraction,
  494. it is noted in the solution.  For example, solving 3 x = 1 gives
  495. x = 0.333333333333333 { 1 / 3 }.  The fraction is reduced, meaning
  496. that the numerator and denominator have no nontrivial factors.  The
  497. logic which recognizes these fractions is particularly effective
  498. with the Exact solver.
  499.  
  500. In some cases, multiple roots for some variable are found.  These
  501. are listed after the list of variable values.
  502.  
  503. If the problem file has a LIST statement, then the list of the
  504. abscissae and ordinate appear in the solution window.
  505.  
  506. The solution always has a list of residuals.  These are extremely
  507. important for assessing the validity and accuracy of a solution.
  508. A residual is a quantity that should be zero if the equation were
  509. solved perfectly.  It is the absolute value of the difference
  510. between the left and right hand sides of the equation.  For
  511. example, solving SIN(x) = .5 might give as a residual
  512.  
  513.    { 1E-16 }  SIN(x)-.5=0
  514.  
  515. The number in braces, 1E-16, is the residual.  It is the absolute
  516. value of SIN(x)-.5 using the solved value of x.  Residuals of this
  517. size are quite common, as internally Mercury calculates to 16-digit
  518. precision, and there is no machine representable x for which SIN(x)
  519. is exactly 0.5.
  520.  
  521. The equation to the right of the braces is often the same as one of
  522. the input equations, but sometimes Mercury rearranges some terms.
  523. It might be a simple rearrangement as above, but it may also the
  524. result of symbolically solving for one of variables and substituting
  525. it into other equations.  In any case, the equations shown with the
  526. residuals are the actual equations used by the solver.  Some control
  527. of the symbolic substitutions is allowed by the LEVEL statement or
  528. the Level option under the Solver menu.
  529.  
  530. Occasionally, you may see variables name T1, T2, ...  These are temporary
  531. variables introduced by Mercury in the course of solving.  Most
  532. commonly, they are used to enforce inequality constraints.
  533. The constraint
  534.  
  535.     EXP(x + y) + y * z <= 10
  536.  
  537. may be replaced with
  538.  
  539.     EXP(x + y) + y * z + T1 = 10
  540.     T1 >= 0
  541.  
  542. The latter has some technical advantages, even though there is an
  543. extra equation and an extra variable.  Values for the extra variable
  544. are not shown.
  545.  
  546. Finally, the solution ends with the largest residual, the method, and
  547. the processor.  The largest residual is simply the maximum of the
  548. previous residuals.  Assuming your problem is not scaled too badly,
  549. then anything less than about 1E-10 should be considered a success.
  550.  
  551. The method is Exact, Direct, or Iterative.  The exact and direct
  552. solvers are more reliable, and Mercury tries them first.  This logic
  553. can be altered with the METHOD statement.  The processor is a 8087,
  554. 80287, 80387, or emulator.
  555.  
  556.  
  557. Reports
  558. -------
  559.  
  560. A report is an unformatted ascii file holding the problem and the
  561. solution.  It can be saved to disk or printed to keep a record of
  562. the solution.  To save to disk, press Go in the Report menu.  (This
  563. menu item doesn't become active until you have solved a problem.)
  564. Normally, the report has the same name as the problem but with the
  565. .EKA suffix replaced with .RPT.  You can use other file names if you
  566. please.
  567.  
  568. Another way to keep a record of problems and solutions is to have
  569. a Log file.  Just turn Capture On in the Report menu.  Then all
  570. problems and solutions will be appended to a log file.
  571.  
  572. The reports and logs are ordinary ascii files, and can be printed.
  573. If you have a Postscript printer, you will have to select a mode
  574. in which it will accept an ascii file, or load a utility for
  575. printing ascii files.  (No such utility is provided with Mercury.)
  576.  
  577.  
  578. Graphics
  579. --------
  580.  
  581. Mercury may be used to generate graphs.  These visually show
  582. the behavior of functions.  A graphics monitor is required.
  583.  
  584. To get a graph, you must first define a function of one variable
  585. in your problem file.  An example from the file BUMPY.EKA is
  586.  
  587.     bumpy(x) := x^2 SIN(x)
  588.  
  589. which defines a function called "bumpy".  The "x" is a dummy variable.
  590. The has values func(0) = 0^2 SIN(0), func(1) = 1^2 SIN(1), etc.  To
  591. graph the function from -15 to +15, use the statements:
  592.  
  593.     PLOT bumpy
  594.     GBOUNDS -15, +15
  595.  
  596. To assimilate this information into the Mercury solver, you must do
  597. a Solve, even though you are not really solving for anything in this
  598. case.  Once the problem has been solved, the View, Print, and Write
  599. commands become available under the Graph menu.  Select View to see
  600. the graph on the screen.
  601.  
  602. If the graph looks a little ragged, perhaps not enough points were
  603. used to plot it.  The default is 30.  Increasing it to 100 will give
  604. a much smoother graph.  This can be done by either adding the
  605. GPOINTS 100 statement to the problem file and solving it again, or
  606. by selecting GPoints from the Graph menu.
  607.  
  608. It is also possible to have "parametric" plots, where both X and
  609. Y are functions of some other independent variable.  Merely use
  610. the XAXIS statement to specify the X function.  The GBOUNDS statement
  611. then refers to the independent variable.
  612.  
  613. These graphs can be printed on graphics printers.  This includes
  614. most printers, except for daisy-wheel printers.  Selecting Print
  615. will print the graph to whatever printer has been selected under
  616. the Options/Printer menu.
  617.  
  618. You can also select Write, which prints the graph to a file.  Such
  619. a file can be sent to a printer at a later time.  The primary
  620. usefulness of this feature is to export the graph in Lotus or
  621. Postscript format, where it can be imported by another program.
  622.  
  623. The various options in the Graph menu are really the defaults, and
  624. are overridden by the corresponding statements in the problem file.
  625. If there are statements in the problem file setting graph options,
  626. then the menu may not accurately reflect the options used to draw
  627. the graph.  Nevertheless, once a graph has been created, these
  628. options can be modified from the graph menu, and then View will
  629. show the revised graph.
  630.  
  631.  
  632. 4. Feature Reference
  633.  
  634. This chapter gives an alphabetical lookup for the Mercury built-in
  635. functions and statements.
  636.  
  637.  
  638. Operators
  639. ---------
  640. +    add.
  641. -    subtract.
  642. *    multiply.  a space may also be used.
  643. /    divide.
  644. ^    power.  Eg, 2^3 = 8.
  645. ~    complex conjugate.
  646. <    less than.
  647. <=    less than.
  648. >    greater than.
  649. >=    greater than.
  650. =    equals.
  651. :=    variable initialization or function definition.
  652. :    equation separator.
  653. %    percent, eg, 17% = .17.
  654.  
  655. These have the usual mathematical precedence rules, with ^ having
  656. higher precedence than * and /, which in turn are higher than + and -.
  657.  
  658.  
  659. Constants
  660. ---------
  661.  
  662. These two constants are built-in.
  663.  
  664. INF    plus infinity
  665. PI    3.1415926535...  You can also use the greek letter by typing Alt-P.
  666.  
  667.  
  668. Functions
  669. ---------
  670.  
  671. Functions take one or more arguments.  The arguments are  separated
  672. by commas and enclosed in parentheses.  Here is a list of the
  673. built-in functions.  Additional functions can be defined within
  674. a problem file.
  675.  
  676. ABS(x)
  677.  
  678. The absolute value of x.  You can also use |x|.
  679.  
  680. ACOS(x)
  681.  
  682. The arc cosine of x, inverse to COS(x).
  683. The result is in radians.
  684.  
  685. ASIN(x)
  686.  
  687. The arc sine of x, inverse to SIN(x).
  688. The result is in radians.
  689.  
  690. ATAN(x)
  691.  
  692. The arc tangent of x, inverse to TAN(x).
  693. The result is in radians.
  694.  
  695. BESSJ(n,x)
  696.  
  697. The Bessel function of the first kind.
  698. The first argument must be an integer.
  699.  
  700. BESSY(n,x)
  701.  
  702. The Bessel function of the second kind, sometimes
  703. also called the Weber function.
  704. The first argument must be an integer.
  705. For each n, it is a solution to Bessel's
  706. differential equation with a singularity at zero.
  707.  
  708. BINOM(n,k)
  709.  
  710. The number of combinations, choosing k of n items.
  711. Given by  n! / (k! (n-k)!).
  712.  
  713. CEIL(x)
  714.  
  715. The smallest integer greater than or equal to x.
  716. Eg, CEIL(4.7) = 5.
  717.  
  718. COS(x)
  719.  
  720. The cosine of x.  The angle x is measured in radians.
  721.  
  722. COSH(x)
  723.  
  724. The hyperbolic cosine of x, (EXP(x) + EXP(-x))/2.
  725.  
  726. CTERM(rate,fv,pv)
  727.  
  728. The number of periods required for a given present
  729. value (pv) to increase to a given future value (fv)
  730. if it grows at the given interest rate.  The function
  731. is compatible with Quattro/Lotus.
  732.  
  733. DERIV(f(x),x)
  734.  
  735. The derivative of the function f(x) with respect to x.
  736. In most cases, the derivative is computed symbolically.
  737.  
  738. DLGAMMA(n,x)
  739.  
  740. The n-th derivative of LOGGAMMA, n = 0,1,2,...
  741.  
  742. ERF(x)
  743.  
  744. The error function of x.  It is related to NCUM(x).
  745.  
  746.          ERF(x) = 2 NCUM(x SQRT(2)) - 1
  747.  
  748. Eg, ERF(-INF) = -1, ERF(0) = 0, ERF(+INF) = +1.
  749.  
  750. ERFC(x)
  751.  
  752. The complementary error function of x.  See ERF and NCUM.
  753.  
  754.           ERFC(x) = 1 - ERF(x)
  755.  
  756. Eg, ERFC(-INF) = +1, ERFC(0) = 0, ERFC(+INF) = -1.
  757.  
  758. EXP(x)
  759.  
  760. The exponential function of x, e^x, e = 2.71828...
  761. It is the inverse to LN(x).
  762.  
  763. FACT(x)
  764.  
  765. x factorial, sometimes written x!.
  766. Eg, FACT(5) = 5*4*3*2*1 = 120.
  767.  
  768. FLOOR(x)
  769.  
  770. The largest integer less than or equal to x.
  771. Eg, FLOOR(4.7) = 4.
  772.  
  773. FRAC(x)
  774.  
  775. The fractional part of x, x - FLOOR(x).
  776. Eg, FRAC(4.7) = 0.7.
  777.  
  778. FV(pmt,rate,nper)
  779.  
  780. The future value of payments (pmt) at the end of nper
  781. periods, assuming the given interest rate.
  782. The function is compatible with Quattro/Lotus.
  783.  
  784. FVAL(rate,nper,pmt,pv)
  785.  
  786. Gives the future value of a financial with a payment
  787. pmt in each of nper periods, with the given present
  788. value pv, and the given interest rate.
  789. The function is compatible with Quattro Pro.
  790. It uses the financial mode specified by the FINANCE
  791. statement to determine whether the payments are at the
  792. end of the period (the default) or the beginning.
  793.  
  794. HYPOT(x,y)
  795.  
  796. The polar coordinate radius corresponding to cartesian
  797. coordinates (x,y).  Eg, HYPOT(3,4) = 5.
  798.  
  799. IFPOS(x,y,z)
  800.  
  801. Gives y if x >= 0, else it gives z.  Eg, IFPOS(-3,6,7) = 7.
  802.  
  803. IM(x)
  804.  
  805. The imaginary part of x.  The COMPLEX option must be in use.
  806.  
  807. INTEG(f(x),x,a,b)
  808.  
  809. INTEG(f(x),x,a,b) gives the numerical integral of f(x) with
  810. respect to x from a to b.  Improper integrals are allowed, so a
  811. can be -INF, b can be +INF, and f can be singular at a or b.  The
  812. approximation method is adaptive and nonlinear, and often is
  813. accurate to 15 digits.
  814.  
  815. INTEG1(f(x),x,a,b)
  816.  
  817. INTEG1 is similar to INTEG, but uses a simpler
  818. strategy.  It is nonadaptive and linear, and may be preferred in
  819. situations where the result is supposed to be a smooth function
  820. of a and b.  INTEG1 is not nearly as accurate as INTEG on
  821. singular functions.
  822.  
  823. LIMIT(f(x),x,a,INF)
  824.  
  825. Estimates the limit of f(x), as x goes from a to infinity.
  826. It uses a numerical method to compute the limit
  827. of f(x), as x goes from a to infinity.  It is an nonlinear
  828. extrapolation based on a fairly small number of terms.  The
  829. limit is only reliable if the function is well-behaved, and
  830. this feature should be used with caution.
  831.  
  832. LN(x)
  833.  
  834. The natural logarithm (base e) of x.
  835. It is the inverse to EXP(x).
  836.  
  837. LOG10(x)
  838.  
  839. The logarithm of x to the base 10.  The inverse is 10^x.
  840.  
  841. LOGGAMMA(x)
  842.  
  843. The logarithm of the gamma function of x.
  844.  
  845. MAX(x,...)
  846.  
  847. The maximum value of the arguments.
  848. Eg, MAX(-10,5,7) = 7.
  849.  
  850. MIN(x,...)
  851.  
  852. The minimum value of the arguments.
  853. Eg, MIN(-10,5,7) = -10.
  854.  
  855. NCUM(x)
  856.  
  857. The normal cumulative probability function.  NCUM(X) is the
  858. probability that a normal random variable is below its mean,
  859. plus X standard deviations.
  860.  
  861. Eg, NCUM(-INF) = 0, NCUM(0) = .5, NCUM(+INF) = 1.
  862.  
  863. PAYMT(rate,nper,pv,fv)
  864.  
  865. Gives the present value of a financial with a payment
  866. pmt in each of nper periods, with the given future
  867. value fv, and the given interest rate.
  868. The function is compatible with Quattro Pro.
  869. It uses the financial mode specified by the FINANCE
  870. statement to determine whether the payments are at the
  871. end of the period (the default) or the beginning.
  872.  
  873. PMT(pv,rate,nper)
  874.  
  875. Gives the amount of the payments required in each of nper
  876. periods to balance the given present value pv and interest rate.
  877. The function is compatible with Quattro/Lotus.
  878.  
  879. POLAR(x,y)
  880.  
  881. The polar coordinate angle corresponding to cartesian (x,y).
  882. Same as the Quattro/Lotus @ATAN2(x,y) or the Fortran/C atan2(y,x).
  883.  
  884. POLY(x,a0,a1,...,an)
  885.  
  886. The polynomial a0 x^n + ... + an.
  887. Eg, the polynomial 2 x^3 - 3 x + 7 can also be written
  888. POLY(x,2,0,-3,7).  The chief advantage of the latter is
  889. notational convenience, and so it can be recognized by the
  890. special polynomial solver.
  891.  
  892. POS(x)
  893.  
  894. The positive part of x, ie, x if positive and 0 if negative.
  895.  
  896. PV(pmt,rate,nper)
  897.  
  898. Gives the present value of nper payments of amount pmt,
  899. using the given interest rate.
  900. The function is compatible with Quattro/Lotus.
  901.  
  902. PVAL(rate,nper,pmt,fv)
  903.  
  904. Gives the present value of a financial with a payment
  905. pmt in each of nper periods, with the given future
  906. value fv, and the given interest rate.
  907. The function is compatible with Quattro Pro.
  908. It uses the financial mode specified by the FINANCE
  909. statement to determine whether the payments are at the
  910. end of the period (the default) or the beginning.
  911.  
  912. RATE(fv,pv,nper)
  913.  
  914. Gives the interest rate required for the present
  915. value (pv) to increase to the future value (fv) in
  916. nper periods.  The function is compatible with Quattro/Lotus.
  917.  
  918. RE(x)
  919.  
  920. The real part of x.  The COMPLEX option must be in use.
  921.  
  922. REM(x,y)
  923.  
  924. The remainder of x divided by y.  Eg, REM(20,3) = 2.
  925.  
  926. SGN(x)
  927.  
  928. Gives +1 if x > 0, -1 if x < 0.
  929.  
  930. SIN(x)
  931.  
  932. The sine of x.  The angle x is measured in radians.
  933.  
  934. SINH(x)
  935.  
  936. The hyperbolic sine of x, (EXP(x) - EXP(-x))/2.
  937.  
  938. SQRT(x)
  939.  
  940. The square root of x.
  941.  
  942. SUM(f(x),x,a,b)
  943.  
  944. The sum of f from a to b,
  945.  
  946.     f(a) + f(a + 1) + ... + f(b)
  947.  
  948. If b = +INF, the limit is estimated as with the LIMIT function.
  949.  
  950. TAN(x)
  951.  
  952. The tangent of x, SIN(x)/COS(x).
  953. The angle x is measured in radians.
  954.  
  955. TANH(x)
  956.  
  957. The hyperbolic tangent of x, SINH(x)/COSH(x).
  958.  
  959. TERM(pmt,rate,fv)
  960.  
  961. The number of periods required for a given payment
  962. stream (pmt) to increase to a given future value (fv)
  963. if it grows at the given interest rate.
  964. The function is compatible with Quattro/Lotus.
  965.  
  966.  
  967. Statements
  968. ----------
  969.  
  970. BOUNDS lower,upper
  971.  
  972. Specify bounds for the domains of the variables.  The default is
  973. BOUNDS -INF,INF.  Some solving time can be saved with the
  974. statement BOUNDS -1e6,1e6 if you are sure that all the relevant
  975. values of your variables are less than a million.
  976.  
  977. CASEFOLD
  978.  
  979. Ignore case in names.  Otherwise, the variable x is different from X.
  980.  
  981. CASESTRICT
  982.  
  983. Using CASESTRICT, with no args, causes built-in functions,
  984. constants, and statements to be upper case only.  Normally such
  985. predefined names are not case sensitive, so SIN(x) is the same as
  986. sin(x).  Using this option reduces the chance of a name conflict.
  987.  
  988. COMPLEX
  989.  
  990. Declares that all the variables are to be considered complex
  991. variables.  Their solutions have a real and imaginary part.
  992. These built-in functions may be used in a complex problem:
  993.  
  994.     ABS, COS, COSH, EXP, IM, LN, RE, SIN, SINH, SQRT,
  995.     SUM, TAN, TANH.
  996.  
  997. DIGITS n
  998.  
  999. Display real numbers to n digits of precision.  The default is 18.
  1000.  
  1001. EPSILON x
  1002.  
  1003. Forces numbers very close to zero to be displayed as zero.  Useful
  1004. for showing complex numbers which are actually real.  Default is EPSILON 0.
  1005.  
  1006. EXTERNAL function
  1007.  
  1008. Declares the name to be an externally defined function, to be
  1009. found on the disk in the problem directory with the file name
  1010. function.BIN.  These functions are written in Turbo C++ or TASM,
  1011. and compiled into .BIN files.  See the samples.
  1012.  
  1013. FINANCE type
  1014.  
  1015. Gives the type parameter to the Quattro compatible financial
  1016. functions, PVAL, PAYMT, and FVAL.  The default is
  1017. type = 0, meaning that the payments are at the end of the
  1018. period.  Use type = 1 if the payments are at the beginning.
  1019.  
  1020. GBOUNDS xleft, xright
  1021.  
  1022. The lower (xleft) and upper (xright) bounds for the X-axis in a graph.
  1023.  
  1024. GPOINTS n
  1025.  
  1026. The number of points (function values) used to draw a graph.  The
  1027. default is 30.  If your graph is too ragged, try increasing the
  1028. number of points.
  1029.  
  1030. GSTYLE n
  1031.  
  1032. Allows graph curves to be thick (GSTYLE 0) or thin (GSTYLE 1).
  1033.  
  1034. INCLUDE filename
  1035.  
  1036. The file with the given name is inserted in the problem at
  1037. that point.  The filename must be in quotes, as in INCLUDE "CONST.INC".  The
  1038. default file name extension is .INC.  Include files cannot be nested.
  1039.  
  1040. ITERATIONS n
  1041.  
  1042. The maximum number of iterations used by the iterative solver.  The
  1043. default is 100.
  1044.  
  1045. LEGEND
  1046.  
  1047. Puts a legend on the graph which identifies the function or functions.
  1048. Recommended when plotting more than one function.
  1049.  
  1050. LEVEL n
  1051.  
  1052. Allows user control over what symbolic substitutions are made.
  1053.  
  1054. 0. no symbolic solving
  1055. 1. solve X = constant
  1056. 2. solve X = constant expression
  1057. 3. solve only when X occurs once, no other variables
  1058. 4. solve only when X occurs once, other variables possible
  1059. 5. solve linear equations
  1060. 6. solve squares, using square roots
  1061. 7. solve quadratic equations
  1062. 8. solve powers
  1063.  
  1064. The default is LEVEL 5, solving linear equations but not using
  1065. square roots.  Strictly speaking, the substitutions involving
  1066. roots are not mathematically equivalent, as the substitution must
  1067. arbitrarily choose the positive or negative square root.
  1068.  
  1069. It is sometimes preferable to use LEVEL 0 to turn off all the
  1070. symbolic manipulations.  Then Mercury effectively weights all
  1071. equations equally, and the solution can be considered the solution
  1072. to a least squares problem.
  1073.  
  1074. LIST function
  1075.  
  1076. List one or more functions in the solution window.  Syntax is the
  1077. same as for PLOT.
  1078.  
  1079. MAXIMIZE x
  1080.  
  1081. The variable x is maximized.
  1082.  
  1083. METHOD n
  1084.  
  1085. Specify the solver method, where n = 1, 2, or 3.
  1086.  
  1087. 1. Exact
  1088. 2. Direct
  1089. 3. Iterative
  1090.  
  1091. The default is METHOD 1, the exact solver.  If it fails, the direct
  1092. solver is tried, and it that also fails, the iterative solver is
  1093. tried.
  1094.  
  1095. MINIMIZE x
  1096.  
  1097. The variable x is minimized.
  1098.  
  1099. PENALTY n
  1100.  
  1101. The value of the penalty constant, an arbitrary constant used
  1102. to enforce constraints when the iterative solver is used to
  1103. maximize or minimize a variable.  The default is 30.  Increasing
  1104. it forces the approximate solutions closer to the constraint
  1105. manifold at the cost of making the extremum harder to find.  Readers
  1106. of The Hitchhiker's Guide to the Galaxy suggest using the value 42.
  1107.  
  1108. PLOT function
  1109.  
  1110. Creates a plot of the named function.  To view the graph, select
  1111. Graph from the main menu.  To plot several functions on the same
  1112. graph, list the names separated by commas.  The functions must be
  1113. defined in the problem file, and be functions of one variable.  For
  1114. example, to plot SIN(x) and x^3-x from -5 to +5, use
  1115.  
  1116.     f(x) := SIN(x)
  1117.     g(x) := x^3 - x
  1118.     GBOUNDS -5, +5
  1119.     PLOT f, g
  1120.  
  1121. PRINT
  1122.  
  1123. Same as PRINTFILE "LPT1".  It prints the graph to the DOS device LPT1,
  1124. which is usually a printer on parallel port 1.  The printing can be
  1125. configured to use another port from the Options menu, and the result
  1126. saved to a setup file.
  1127.  
  1128. PRINTFILE filename
  1129.  
  1130. Print the graph to the given file, whose name is in quotes.
  1131.  
  1132. These names have special meaning.
  1133.  
  1134.     "PAR1"    parallel port 1
  1135.     "SER1"    serial port 1
  1136.     "PAR2"    parallel port 2
  1137.     "SER2"    serial port 2
  1138.     "LPT1"    DOS lpt1
  1139.     "LPT2"    DOS lpt2
  1140.     "LPT3"    DOS lpt3
  1141.     "LPT4"    DOS lpt4
  1142.     "EPT"    IBM postscript port
  1143.  
  1144. PROGRESS x
  1145.  
  1146. Show the value of the variable x in the Progress box.  Mercury
  1147. does not solve for all variables at once, so sometimes there
  1148. might be no value for the variable until the end of the solution
  1149. process.  In such cases, the Progress window shows "x = NAN",
  1150. meaning "x is not a number".  
  1151.  
  1152. If no PROGRESS statement is given, the Progress window shows the
  1153. value of the "Residual".  This is the sum of squares of quantities
  1154. which should be zero, and which Mercury is trying to minimize.  The
  1155. smaller the value, the more likely that Mercury is getting close to
  1156. the solution.
  1157.  
  1158. REPORT filename
  1159.  
  1160. Allows naming a report file from within a problem.
  1161.  
  1162. ROOTSIGN n
  1163.  
  1164. When solving an equation like x^2 = a, Mercury may take the square
  1165. root of both sides.  This introduces two roots, +SQRT(a) and
  1166. -SQRT(a), and Mercury does not know which to take.  You can specify
  1167. that you always want the positive root with ROOTSIGN +1, or
  1168. always the negative root with ROOTSIGN -1.  The default is
  1169. ROOTSIGN 0, which leaves Mercury unable to evaluate the square
  1170. root.
  1171.  
  1172. SCREEN n
  1173.  
  1174. Choose a graphics screen.  The default is SCREEN 0, which means
  1175. Mercury automatically tries to detect your graphics hardware.
  1176. Some graphics cards and modes cannot be detected, and must be
  1177. selected with a SCREEN statement.
  1178.  
  1179.     0.    AutoDetect
  1180.     1.    CGA
  1181.     2.    MCGA
  1182.     3.    EGA 64k
  1183.     4.    EGA 256k
  1184.     5.    EGA Mono
  1185.     6.    IBM 8514
  1186.     7.    Hercules
  1187.     8.    ATT 400 line
  1188.     9.    VGA
  1189.     10.    3270 PC
  1190.     11.    Tandy 1000
  1191.     12.    ATI Super VGA
  1192.     13.    Orchid Super VGA
  1193.     14.    Paradise Super VGA
  1194.     15.    Vega Super VGA
  1195.     16.    Compro ABLE II Super VGA
  1196.     17.    SOTA Super VGA
  1197.  
  1198. From the main menu, the graphics screen can be selected with
  1199. Graph/Mode.  Such a selection is ineffective after the first
  1200. graph is drawn, as the graphics has been initialized at that
  1201. point.  We recommend saving the desired graphics mode to the
  1202. MERCURY.CFG configuration file.
  1203.  
  1204. (Note: The drivers for some of these graphics modes is not
  1205. included with some versions of Mercury.  Registered customers
  1206. receive the full set of drivers.)
  1207.  
  1208. SHOW x
  1209.  
  1210. Show specified variables in the specified order.  Other variables
  1211. are not displayed in the solution window.
  1212.  
  1213. SOLVE x
  1214.  
  1215. Instructs Mercury to solve only for the variable x.  By default, it
  1216. solves for all variables named in the problem.
  1217.  
  1218. If SOLVE is given with a polynomial function name, as in
  1219.  
  1220.     SOLVE f
  1221.     f(x) := POLY(x,1,0,0,1)
  1222.  
  1223. then Mercury will apply a special polynomial root finder to get all
  1224. real and complex roots.
  1225.  
  1226. START x
  1227.  
  1228. The starting value for uninitialized variables while using the
  1229. iterative solver.  The default is 1.00.
  1230.  
  1231. TERMS n
  1232.  
  1233. The most number of terms used by the INTEG and LIMIT functions.  The
  1234. default is 50.
  1235.  
  1236. TIME n
  1237.  
  1238. The maximum time allowed for solution.  The default is 200 seconds.
  1239. Same as MAXTIME in Eureka 1.0.
  1240.  
  1241. TITLE label
  1242.  
  1243. Argument is a quoted string, to be used as a graph title.
  1244. Default is no title.
  1245.  
  1246. SUBTITLE label
  1247.  
  1248. Argument is a quoted string, to be used as a graph subtitle.
  1249. Default is no title.
  1250.  
  1251. XLABEL label
  1252.  
  1253. A label for the X-axis of a graph.  The label must be in quotes.
  1254.  
  1255. YLABEL label
  1256.  
  1257. A label for the Y-axis of a graph.  The label must be in quotes.
  1258.  
  1259. XAXIS function
  1260.  
  1261. Specifies that the X-axis be a function instead of an independent
  1262. variable.  The function must be defined elsewhere as a function
  1263. of one variable.  
  1264.  
  1265. The X axis of the graph is a function with the given name.  Useful
  1266. for parametric plots.  Eg, to graph (x,y) = (cos(t),sin(t)) as
  1267. t goes from 0 to 2*PI, use
  1268.  
  1269.     x(t) := cos(t)
  1270.     y(t) := sin(t)
  1271.     GBOUNDS 0, 2 PI
  1272.     XAXIS x
  1273.     PLOT y
  1274.  
  1275.  
  1276.